
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import net.sourceforge.floggy.persistence.FloggyException;
import net.sourceforge.floggy.persistence.PersistableManager;

public class DMath extends MIDlet {

    private static DMath instance;
    private final Menu menu;
    private final Splash splash;

    public DMath() {
        instance = this;
        menu = new Menu(); 
        splash = new Splash();
    }

    protected void destroyApp(boolean a) {
        try {
            PersistableManager.getInstance().shutdown();
        } catch (FloggyException ex) {
            ex.printStackTrace();
        }
        notifyDestroyed();
    }

    protected void pauseApp() {
    }

    protected void startApp() {
        getDisplay().setCurrent(splash);
        splash.play();
        
        getDisplay().setCurrent(menu);
    }

    public Display getDisplay() {
        return Display.getDisplay(this);
    }

    public static DMath getInstance() {
        return instance;
    }
}
